package com.wgtgt.code_convert;

/**
 * Hello world!
 *
 */
public class App {
	public static void main(String[] args) {
		System.out.println("Hello World!");
		String code = "@";
//		String code = "abc== \"abc\"";
		String cc = codey(code);
		System.out.println("------");
		System.out.println(cc);
	}

	private static String codey(String code) {
		if (!"@".equals(code.trim()) && code.startsWith("@")) {
			code = code.substring(1);
			int index = code.indexOf(" ");
			if (index == -1) {
				return code;
			}
			String left = code.substring(0, index);
			String right = code.substring(index + 1);
			left = left.trim();
			right = right.trim();
			StringBuilder sb = new StringBuilder();
			sb.append("@Param(\"");
			sb.append(right);
			sb.append("\")");
			sb.append(left);
			sb.append(" ");
			sb.append(right);
			return sb.toString();
		}
		return code;
	}

	private static String codex(String code) {
		if (code.contains("==")) {
			int lastIndexOf = code.lastIndexOf("==");
			String left = code.substring(0, lastIndexOf);
			String right = code.substring(lastIndexOf + 2);
			System.out.println("left =" + left);
			System.out.println("right =" + right);
			left = left.trim();
			right = right.trim();
			if ("null".equals(right)) {
				return code;
			}
			if (!right.contains("\"")) {
				return code;
			}
			StringBuilder sb = new StringBuilder();
			sb.append(right);
			sb.append(".equals(");
			sb.append(left);
			sb.append(")");
			return sb.toString();
		}
		return code;
	}
}
